/**
 * @Author: Sagan
 * @Date: 2020/09/17 16:13
 */
package lang

import (
	"reflect"
)

func GetType(v interface{}) reflect.Kind {
	rt := reflect.TypeOf(v)

	if nil == rt {
		return reflect.Invalid
	}

	if reflect.Ptr == rt.Kind() {
		rt = rt.Elem()
	}

	return rt.Kind()
}

func GetValue(v interface{}) (interface{}, reflect.Kind) {
	rt := reflect.TypeOf(v)

	if nil == rt {
		return nil, reflect.Invalid
	}

	rv := reflect.ValueOf(v)

	if reflect.Ptr == rv.Kind() {
		rv = rv.Elem()
	}

	return rv.Interface(), rv.Kind()
}
